<template>
  <loginView
    @sub="sub"
  >
  </loginView>
</template>

<script>

  import loginView from './loginView'

  export default {

    components: {
      loginView
      // name
    },
    name: "loginLogic",
    props: {
      // msg: String //  [name: typeof]
    },
    filters: {},
    computed: {},
    watch: {},
    data() {
      return {}
    },
    created() {

    },
    mounted() {
      console.log("123", location.href);
    },
    methods: {
      sub(us) {
        if (us.password == '' || us.username == '') {
          this.$message({
            type: 'error',
            message: '用户名或密码不能为空!'
          });
          return;
        }

        let newObj = {
          pwd: us.password,
          userName: us.username
        }
        _https.post.login(newObj).then((res) => {
          if (res.status == 200) {
            switch (res.data.code) {
              case 9999 :
                this.$message({
                  type: 'error',
                  message: `${res.data.message}！`
                });
                break;
              case 9998:
                this.$message({
                  type: 'error',
                  message: `${res.data.message}！`
                });
                break;
              case 9997:
                this.$message({
                  type: 'error',
                  message: `${res.data.message}！`
                });
                break;
              case 0:
                let session = window.sessionStorage;
                let userData = res.data.data;
                session.setItem("userData", userData);
                this.$router.push('/frame');
                break;
            }
            // if (res.data.code == '9999') {
            //   this.$message({
            //     type: 'error',
            //     message: `${res.data.message}！`
            //   });
            //   return;
            // } else if (res.data.code == '9998') {
            //   this.$message({
            //     type: 'error',
            //     message: `${res.data.message}！`
            //   });
            //   return;
            // } else if (res.data.code == '9997') {
            //   this.$message({
            //     type: 'error',
            //     message: `${res.data.message}！`
            //   });
            //   return;
            // } else {
            //   let session = window.sessionStorage;
            //   let userData = res.data.data;
            //   session.setItem("userData", userData);
            //   this.$router.push('/frame');
            // }
          }
        }).catch((err) => {
          console.log('loginerr', err);
        });
      }
    },
    destroyed() {

    }
  }
</script>

<style scoped lang="less">

</style>
